<?php

namespace Acme\DemoBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Acme\DemoBundle\Entity\Chung;

class ChungController extends Controller
{
	
	
	
	public function detailAction($id)
	{
		$Chung = $this->getDoctrine()
		->getRepository('AcmeDemoBundle:Chung')
		->find($id);
		 
		return $this->render(
				'AcmeDemoBundle:Demo:Chung_edit.html.twig',
				array('Chung' => $Chung,'thongbao' => null)
		);
	}
	public function editAction($id)
	{
		$Chung = $this->getDoctrine()
		->getRepository('AcmeDemoBundle:Chung')
		->find($id);
		$request = $this->get('request');

		$luongcoban = str_replace(',','',$request->request->get('luongcoban'));
		$luongcvcoban = str_replace(',','',$request->request->get('luongcvcoban'));
		$luongbaohiem = str_replace(',','',$request->request->get('luongbaohiem'));
		$hesolamtham = str_replace(',','',$request->request->get('hesolamtham'));
		$luonggiamdoc = str_replace(',','',$request->request->get('luonggiamdoc'));
		$luongnhanvien = str_replace(',','',$request->request->get('luongnhanvien'));
		$ngaytinhcong = str_replace(',','',$request->request->get('ngaytinhcong'));
		$hesoBHXH = str_replace(',','',$request->request->get('hesoBHXH'));
		$hesoBHYT = str_replace(',','',$request->request->get('hesoBHYT'));
		$hesoBHTN = str_replace(',','',$request->request->get('hesoBHTN'));
		
		
		$tongngaycong = $request->request->get('tongngaycong');
		$tienantrua = str_replace(',','',$request->request->get('tienantrua'));
		
		$Chung->setLuongcoban($luongcoban);
		$Chung->setLuongcvcoban($luongcvcoban);
		$Chung->setLuongbaohiem($luongbaohiem);
		$Chung->setHesolamtham($hesolamtham);
		$Chung->setLuonggiamdoc($luonggiamdoc);
		$Chung->setLuongnhanvien($luongnhanvien);
		
		$Chung->setNgaytinhcong($ngaytinhcong);
		$Chung->setHesoBHXH($hesoBHXH);
		$Chung->setHesoBHYT($hesoBHYT);
		$Chung->setHesoBHTN($hesoBHTN);
		
		
		$Chung->setTongngaycong($tongngaycong);
		$Chung->setTienantrua($tienantrua);
		$Chung->setUpdated(new \DateTime('now'));
		$this->getDoctrine()
		->getRepository('AcmeDemoBundle:Chung')
		->saveChung($Chung);
		return $this->render(
				'AcmeDemoBundle:Demo:Chung_edit.html.twig',
				array('Chung' => $Chung,'thongbao' => 'ok')
		);
		


	}
	
}
